﻿
using System;
using log4net;
using log4net.Appender;


namespace SarsClient
{
	/// <summary>
	/// Class for Logging.
	/// </summary>
	public static class Logging
	{
		static ILog logger;
		
		/// <summary>
		/// Return Log4net logger instance.
		/// </summary>
		public static ILog Logger {
			get { return logger; }
		}
		
		
		static IAppender appender;
		
		// forwarding appender for log messages
		static BufferingForwardingAppender forwarder;
		
		/// <summary>
		/// Return BufferingForwardingAppender.
		/// </summary>
		public static BufferingForwardingAppender Forwarder {
			get { return forwarder; }
		}
		
		/// <summary>
		/// Static constructor.
		/// Initializes log4net and class members.
		/// </summary>
		static Logging(){
			
			forwarder = new BufferingForwardingAppender();
			appender = forwarder;
			
			log4net.Layout.ILayout stdLayout = new log4net.Layout.SimpleLayout();
			
			logger = log4net.LogManager.GetLogger("default");
			log4net.Config.BasicConfigurator.Configure(appender);
			forwarder.AddAppender(new log4net.Appender.DebugAppender(stdLayout));
		}

	}
}
